package pack1014;

import java.util.Arrays;

// 对象数组
public class DemoC {

    private static void a() {
        int[] array1 = {3, 4, 5, 6};
        int a = 9;
        Student s1 = new Student();
        s1.gender = '男';
        s1.birthday = "2003-1-1";
        s1.id = 1;
        s1.name = "代常瑞";
        Student s2 = new Student();
        s2.gender = '女';
        s2.birthday = "2004-1-1";
        s2.id = 2;
        s2.name = "郝雨萌";
        Student[] array2 = {s1, s2};
        System.out.println(Arrays.toString(array2));
        for (int i = 0; i < array2.length; i++) {
            Student s = array2[i];
            s.print();
        }
    }

    // 数组是值传递还是引用传递
    private static void b1() {
        int a = 1;
        int b = 2;
        int c = 3;
        int[] array = {a, b, c};
        System.out.println(Arrays.toString(array));
        System.out.println("a:" + a + ",b:" + b + ",c:" + c);
        System.out.println("---------------------------------");
        a = 6;
        b = 7;
        c = 8;
        System.out.println(Arrays.toString(array));
        System.out.println("a:" + a + ",b:" + b + ",c:" + c);
    }

    private static void b2() {
        Student s1 = new Student();
        s1.gender = '男';
        s1.birthday = "2003-1-1";
        s1.id = 1;
        s1.name = "代常瑞";
        Student s2 = new Student();
        s2.gender = '女';
        s2.birthday = "2004-1-1";
        s2.id = 2;
        s2.name = "郝雨萌";
        Student s3 = new Student();
        s3.gender = '男';
        s3.birthday = "2004-6-5";
        s3.id = 3;
        s3.name = "陈志伟";
        Student[] array = {s1, s2, s3};
        System.out.println("改变之前：");
        s1.print();
        s2.print();
        s3.print();
        for (Student student : array) {
            student.print();
        }
        System.out.println("------------------------------------------");
        s2.name = "郝佳怡";
        System.out.println("改变之后：");
        s1.print();
        s2.print();
        s3.print();
        for (Student student : array) {
            student.print();
        }
    }

    public static void main(String[] args) {
        a();
    }
}
